Constructs an EventHandler for the specified delegate converting it to the expected EventHandler<TEventArgs> delegate type.
Syntax
Parameters
- control
- handler
Example
Library/Library.Test/TestDelegates.cs
C# | Copy Code |
---|
EventHandler<VerifiedReceiptEventArgs> handler;
VerifiedReceiptEventArgs args = new VerifiedReceiptEventArgs();
_thread.Start();
_form.FormCreated.WaitOne();
handler = new EventHandlerForControl<VerifiedReceiptEventArgs>(_form, VerifiedReceipt);
handler(null, args.Reset());
Assert.IsTrue(args.Received);
Assert.IsTrue(args.OnThread);
handler = new EventHandlerForControl<VerifiedReceiptEventArgs>(_form, new VerifiedReceiptEventHandler(VerifiedReceiptRedirect));
handler(null, args.Reset());
Assert.IsTrue(args.Received);
Assert.IsTrue(args.OnThread);
_form.BeginInvoke((Action)_form.Close);
_thread.Join(); |
VB.NET | Copy Code |
---|
Dim handler As EventHandler(Of VerifiedReceiptEventArgs)
Dim args As New VerifiedReceiptEventArgs()
_thread.Start()
_form.FormCreated.WaitOne()
handler = New EventHandlerForControl(Of VerifiedReceiptEventArgs)(_form, VerifiedReceipt)
handler(Nothing, args.Reset())
Assert.IsTrue(args.Received)
Assert.IsTrue(args.OnThread)
handler = New EventHandlerForControl(Of VerifiedReceiptEventArgs)(_form, New VerifiedReceiptEventHandler(VerifiedReceiptRedirect))
handler(Nothing, args.Reset())
Assert.IsTrue(args.Received)
Assert.IsTrue(args.OnThread)
_form.BeginInvoke(DirectCast(_form.Close, Action))
_thread.Join() |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also